<?php
/*
	Muffinz CMS - A website content management system.
	Copyright (C) 2010-2011 Sigitas Zelenkovas

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
	
	Optionally you can also view the license at <http://www.gnu.org/licenses/>.
*/

class Plugin_MenuPanels{	
	public function Add($text, $link, $toMain = true, $ali = true){
		global $cTheme;
		if($toMain){
			$cTheme->AddMenuItem($text, $link);
		}
		$this->panelMenuItems[] = array($text, $link, $ali);
		
	}
	
	public function Set(){
		global $cTheme;
		$buffer = "";
		foreach($this->panelMenuItems as $item){
			if($item[2] == true){
				$buffer .= "<li><a href=\"{$item[1]}\"><span class=\"bullet\">&middot;&nbsp;</span><span>{$item[0]}</span></a></li>";
			}else {
				$buffer .= "<li><span>{$item[0]}</span></li>";
			}
		}
		$cTheme->AddPanel("Admin menu", $buffer, 1);
	}
	
	public function AddPanel($name, $items, $ord = 1){
		global $cTheme;
		$buffer = "";
		foreach($items as $item){
			if(@!$item[2]){
				$buffer .= "<li><a href=\"{$item[1]}\"><span class=\"bullet\">&middot;&nbsp;</span><span>{$item[0]}</span></a></li>";
			}else {
				$buffer .= "<li><span class=\"bullet\">&middot;&nbsp;</span><span><s>{$item[0]}</s></span></li>";
			}
		}
		$cTheme->AddPanel($name, $buffer, $ord);
	}
}

$PluginMenuPanel = new Plugin_MenuPanels();

$menus = array();
$menus[] = array("Overview", "{$_SESSION['sys']['core_link_full']}{$_SESSION['sys']['core_link']}{$_SESSION['sys']['core_link_admin']}index.php");
$menus[] = array("News", "{$_SESSION['sys']['core_link_full']}{$_SESSION['sys']['core_link']}{$_SESSION['sys']['core_link_admin']}index.php?page=news");
$PluginMenuPanel->AddPanel("Main", $menus, 1);

$menus = array();
$menus[] = array("List plugins", "{$_SESSION['sys']['core_link_full']}{$_SESSION['sys']['core_link']}{$_SESSION['sys']['core_link_admin']}index.php?page=plugins");
$menus[] = array("Upload plugins", "{$_SESSION['sys']['core_link_full']}{$_SESSION['sys']['core_link']}{$_SESSION['sys']['core_link_admin']}index.php?page=plugins&do=upload");
$menus[] = array("Delete plugins", "{$_SESSION['sys']['core_link_full']}{$_SESSION['sys']['core_link']}{$_SESSION['sys']['core_link_admin']}index.php?page=plugins&do=delete");
$PluginMenuPanel->AddPanel("Plugin management", $menus, 2);

$menus = array();
$menus[] = array("List users", "{$_SESSION['sys']['core_link_full']}{$_SESSION['sys']['core_link']}{$_SESSION['sys']['core_link_admin']}index.php?page=users");
$menus[] = array("Add user", "{$_SESSION['sys']['core_link_full']}{$_SESSION['sys']['core_link']}{$_SESSION['sys']['core_link_admin']}index.php?page=users&action=add");
$menus[] = array("Admin accounts", "{$_SESSION['sys']['core_link_full']}{$_SESSION['sys']['core_link']}{$_SESSION['sys']['core_link_admin']}index.php?page=users&action=admin");
$PluginMenuPanel->AddPanel("User management", $menus, 3);

$menus = array();
$menus[] = array("Settings", "{$_SESSION['sys']['core_link_full']}{$_SESSION['sys']['core_link']}{$_SESSION['sys']['core_link_admin']}index.php?page=settings");
$menus[] = array("Global variables", "{$_SESSION['sys']['core_link_full']}{$_SESSION['sys']['core_link']}{$_SESSION['sys']['core_link_admin']}index.php?page=global-variables");
$PluginMenuPanel->AddPanel("System", $menus, 4);